<template>
  <div class="wrap-box">
    <div class="bg">
      <div class="main-box">
        <div class="title">{{ resData.screenName }}</div>
        <div class="cnt-box">
          <div class="swiper">
            <div class="swiper-wrapper">
              <div class="swiper-slide" v-for="(item, index) in list" :key="index">
                <div class="img-box">
                  <div class="mask"></div>
                  <img :src="item.picUrl">
                </div>
              </div>
            </div>
          </div>
          <div class="text-box">
            <div v-if="list.length" v-html="list[index].word"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {getPicWord} from "@/api"
import Swiper from'swiper';
export default {
  name: "home",
  data() {
    return {
      list: [],
      resData: {},
      index: 0,
    }
  },
  components: {

  },
  created() {
  },
  mounted() {
    this.getPicWord();
  },
  methods: {
    getPicWord(){
      getPicWord().then(res => {
        this.resData = res.content[0];
        let json = res.content[0].data;
        this.list = JSON.parse(json);
        this.$nextTick(() => {
          this.initSwiper()
        })
      }).catch(err => {
        console.log(err);
      })
    },
    initSwiper(){
      this.swiper = new Swiper('.swiper', {
        autoplay: true,
        delay: 5000,
        loop: true,
        observer: true,
        observeParents: true,
        effect: "coverflow",
        centeredSlides: true,
        slidesPerView: 'auto',
        coverflowEffect: {
          rotate: 30,
          stretch: '52%',
          depth: 290,
          modifier: 1,
          slideShadows: true,
        },
        on: {
          slideChange: () => {
            if(this.swiper){
              this.index = this.swiper.realIndex
            }
          },
        },
      })
    },
  }
};
</script>

<style lang="scss" scoped>
.wrap-box {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0 20px;
  background: rgba(15, 25, 46, 1);
  overflow: auto;
}

.bg {
  position: relative;
  width: 100%;
  height: 100%;
  background: url("~@/assets/home/bg.png") no-repeat;
  background-size: 100% 100%;
  padding-top: 118px;
  padding-bottom: 54px;
  display: flex;
  overflow: hidden;
  .main-box{
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    //justify-content: center;
    align-items: center;
    overflow: hidden;
  }
  .title{
    width: 711px;
    height: 70px;
    min-height: 70px;
    background: url("~@/assets/imgText/titbg.png") no-repeat;
    background-size: 100% 100%;
    color: #ffffffcc;
    text-align: center;
    font-family: "Source Han Sans CN";
    font-weight: 700;
    font-size: 32px;
    line-height: 26px;
    letter-spacing: 10px;
    padding-top: 20px;
  }
  .cnt-box{
    width: 1659px;
    height: 758px;
    background: url("~@/assets/imgText/mainbg.png") no-repeat;
    background-size: 100% 100%;
    margin-top: 20px;
    padding: 28px 128px;
  }
  .swiper{
    width: 100%;
    height: 542px;
    overflow: hidden;
    .swiper-slide{
      width: 722px!important;
      height: 542px!important;
    }
    .swiper-slide-active {
      .img-box .mask{
        opacity: 0;
      }
    }
  }
  .img-box{
    position: relative;
    width: 722px;
    height: 542px;
    .mask{
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.2);
      z-index: 1;
      transition: all 1s;
    }
    img{
      width: 100%;
      height: 100%;
    }
  }
  .text-box{
    margin-top: 24px;
    color: #ffffffcc;
    //font-family: "Source Han Sans CN";
    font-weight: 500;
    font-size: 20px;
    line-height: 30px;
    //p{
    //  text-indent: 40px;
    //  color: #ffffffcc;
    //  //font-family: "Source Han Sans CN";
    //  font-weight: 500;
    //  font-size: 20px;
    //  line-height: 30px;
    //}
  }
}
</style>